<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMessageTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('message', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('user_id')->default('0')->comment('用户id（被动通知）');
            $table->integer('from_user_id')->default('0')->nullable()->comment('消息来源用户（主动发起，系统消息为0）');
            $table->string('content')->default('')->comment('消息内容');
            $table->tinyInteger('is_read')->default('0')->comment('是否已读 0否；1是');
            $table->char('relation_type')->comment('关联模型');
            $table->integer('relation_id')->default('0')->comment('关联id');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('message');
    }
}
